<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class CreateArticlesTable extends Migration
{
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');

            $table->string('title');
            $table->unsignedInteger('creator_id');
            $table->unsignedInteger('category_id');
            $table->unsignedInteger('keyword_id')->default(0)->comment('keywords表的ID');
            $table->string('catalogue')->default('')->comment('目录名称');
            $table->string('slug')->default('')->comment('slug');
            $table->string('cover')->default('')->comment('封面图');
            $table->boolean('recommend')->default(false)->comment('推荐');
            $table->string('seo_title')->default('')->comment('seo的标题');
            $table->string('seo_keywords')->default('')->comment('seo的关键词');
            $table->string('seo_description')->default('')->comment('seo的描述');
            $table->unsignedInteger('views_count')->default(0)->comment('查看统计');
            $table->unsignedTinyInteger('verify_status')->default(0)->comment('审核状态，具体见模型');

            $table->timestamps();
            $table->timestamp('published_at')->nullable()->comment('发布时间');

            $table->softDeletes();

            $table->text('content');

            $table->unique(['slug', 'catalogue']);
        });
    }
}
